<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class TypeProf::Type::Array::Elements - typeprof: Ruby Standard Library Documentation</title>


<script src="../../../js/navigation.js" defer></script>
<script src="../../../js/search.js" defer></script>
<script src="../../../js/search_index.js" defer></script>
<script src="../../../js/searcher.js" defer></script>
<script src="../../../js/darkfish.js" defer></script>

<script src="../../../js/jquery-3.2.0.min.js"></script>

<script src="../../../js/vue.min.js"></script>
<script src="../../../js/js.cookie.min.js"></script>

<link href="../../../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../../../css/rdoc.css" rel="stylesheet">
<link href="../../../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../../../";
  var index_rel_prefix = "../../../";
  var darkModeCsseHref = "../../../css/rdoc-dm.css"
  var defaultModeCssHref = "../../../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../../../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../../../table_of_contents.html#pages">Pages</a>
    <a href="../../../table_of_contents.html#classes">Classes</a>
    <a href="../../../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link"><a href="../../../Object.html">Object</a>
</div>

        
<div id="includes-section" class="nav-section">
  <h3>Included Modules</h3>

  <ul class="link-list">
    <li><a class="include" href="../../Utils/StructuralEquality.html">TypeProf::Utils::StructuralEquality</a>
  </ul>
</div>

        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-dummy_elements">::dummy_elements</a>
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-i-5B-5D">#[]</a>
    <li ><a href="#method-i-append">#append</a>
    <li ><a href="#method-i-each_free_type_variable">#each_free_type_variable</a>
    <li ><a href="#method-i-globalize">#globalize</a>
    <li ><a href="#method-i-include_untyped-3F">#include_untyped?</a>
    <li ><a href="#method-i-limit_size">#limit_size</a>
    <li ><a href="#method-i-localize">#localize</a>
    <li ><a href="#method-i-match-3F">#match?</a>
    <li ><a href="#method-i-pretty_print">#pretty_print</a>
    <li ><a href="#method-i-screen_name">#screen_name</a>
    <li ><a href="#method-i-squash">#squash</a>
    <li ><a href="#method-i-squash_or_any">#squash_or_any</a>
    <li ><a href="#method-i-substitute">#substitute</a>
    <li ><a href="#method-i-take_first">#take_first</a>
    <li ><a href="#method-i-take_last">#take_last</a>
    <li ><a href="#method-i-to_local_type">#to_local_type</a>
    <li ><a href="#method-i-union">#union</a>
    <li ><a href="#method-i-update">#update</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-TypeProf::Type::Array::Elements">
    <h1 id="class-TypeProf::Type::Array::Elements" class="class">
      class TypeProf::Type::Array::Elements
    </h1>

    <section class="description">
    
    </section>

      <section id="5Buntitled-5D" class="documentation-section">



        <section class="attribute-method-details" class="method-section">
        <header>
        <h3>Attributes</h3>
        </header>

          <div id="attribute-i-lead_tys" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">lead_tys</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              
              </div>
            </div>
          <div id="attribute-i-rest_ty" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">rest_ty</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              
              </div>
            </div>
            </section>


                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-dummy_elements" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">dummy_elements</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="dummy_elements-source">
            <pre><span class="ruby-comment"># File typeprof-0.21.8/lib/typeprof/container-type.rb, line 274</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">dummy_elements</span>
  <span class="ruby-constant">Elements</span>.<span class="ruby-identifier">new</span>([], <span class="ruby-constant">Type</span>.<span class="ruby-identifier">any</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-new" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">new</span><span
                                class="method-args">(lead_tys, rest_ty = Type.bot)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File typeprof-0.21.8/lib/typeprof/container-type.rb, line 268</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">lead_tys</span>, <span class="ruby-identifier">rest_ty</span> = <span class="ruby-constant">Type</span>.<span class="ruby-identifier">bot</span>)
  <span class="ruby-identifier">raise</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">lead_tys</span>.<span class="ruby-identifier">all?</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">ty</span><span class="ruby-operator">|</span> <span class="ruby-identifier">ty</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Type</span>) }
  <span class="ruby-identifier">raise</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">rest_ty</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Type</span>)
  <span class="ruby-ivar">@lead_tys</span>, <span class="ruby-ivar">@rest_ty</span> = <span class="ruby-identifier">lead_tys</span>, <span class="ruby-identifier">rest_ty</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-5B-5D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">[]</span><span
                                class="method-args">(idx)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="5B-5D-source">
            <pre><span class="ruby-comment"># File typeprof-0.21.8/lib/typeprof/container-type.rb, line 373</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">[]</span>(<span class="ruby-identifier">idx</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">idx</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Range</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-ivar">@rest_ty</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Type</span>.<span class="ruby-identifier">bot</span>
      <span class="ruby-identifier">lead_tys</span> = <span class="ruby-ivar">@lead_tys</span>[<span class="ruby-identifier">idx</span>]
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">lead_tys</span>
        <span class="ruby-identifier">rest_ty</span> = <span class="ruby-constant">Type</span>.<span class="ruby-identifier">bot</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-keyword">return</span> <span class="ruby-constant">Type</span>.<span class="ruby-identifier">nil</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">b</span>, <span class="ruby-identifier">e</span> = <span class="ruby-identifier">idx</span>.<span class="ruby-identifier">begin</span>, <span class="ruby-identifier">idx</span>.<span class="ruby-identifier">end</span>
      <span class="ruby-identifier">b</span> = <span class="ruby-value">0</span> <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">b</span>
      <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">e</span>
        <span class="ruby-identifier">lead_tys</span> = <span class="ruby-ivar">@lead_tys</span>[<span class="ruby-identifier">idx</span>] <span class="ruby-operator">||</span> []
        <span class="ruby-identifier">rest_ty</span> = <span class="ruby-ivar">@rest_ty</span>
      <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">b</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-value">0</span>
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">e</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-value">0</span>
          <span class="ruby-keyword">if</span> <span class="ruby-identifier">b</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">e</span>
            <span class="ruby-keyword">if</span> <span class="ruby-identifier">e</span> <span class="ruby-operator">&lt;</span> <span class="ruby-ivar">@lead_tys</span>.<span class="ruby-identifier">size</span>
              <span class="ruby-identifier">lead_tys</span> = <span class="ruby-ivar">@lead_tys</span>[<span class="ruby-identifier">idx</span>]
              <span class="ruby-identifier">rest_ty</span> = <span class="ruby-constant">Type</span>.<span class="ruby-identifier">bot</span>
            <span class="ruby-keyword">else</span>
              <span class="ruby-identifier">lead_tys</span> = <span class="ruby-ivar">@lead_tys</span>[<span class="ruby-identifier">idx</span>] <span class="ruby-operator">||</span> []
              <span class="ruby-identifier">rest_ty</span> = <span class="ruby-ivar">@rest_ty</span>
            <span class="ruby-keyword">end</span>
          <span class="ruby-keyword">else</span>
            <span class="ruby-keyword">return</span> <span class="ruby-constant">Type</span>.<span class="ruby-identifier">nil</span>
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">else</span>
          <span class="ruby-identifier">lead_tys</span> = <span class="ruby-ivar">@lead_tys</span>[<span class="ruby-identifier">idx</span>] <span class="ruby-operator">||</span> []
          <span class="ruby-identifier">e</span> = <span class="ruby-identifier">idx</span>.<span class="ruby-identifier">exclude_end?</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">e</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">e</span> <span class="ruby-operator">==</span> <span class="ruby-value">-1</span> <span class="ruby-operator">?</span> <span class="ruby-ivar">@lead_tys</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">e</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
          <span class="ruby-identifier">rest_ty</span> = (<span class="ruby-ivar">@lead_tys</span>[<span class="ruby-identifier">e</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span><span class="ruby-operator">..</span>] <span class="ruby-operator">||</span> []).<span class="ruby-identifier">inject</span>(<span class="ruby-ivar">@rest_ty</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">ty0</span>, <span class="ruby-identifier">ty1</span><span class="ruby-operator">|</span> <span class="ruby-identifier">ty0</span>.<span class="ruby-identifier">union</span>(<span class="ruby-identifier">ty1</span>) }
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">lead_tys</span> = []
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">e</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-value">0</span>
          <span class="ruby-identifier">rest_ty</span> = <span class="ruby-identifier">e</span> <span class="ruby-operator">&lt;</span> <span class="ruby-ivar">@lead_tys</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">?</span> <span class="ruby-constant">Type</span>.<span class="ruby-identifier">bot</span> <span class="ruby-operator">:</span> <span class="ruby-ivar">@rest_ty</span>
          <span class="ruby-identifier">range</span> = [<span class="ruby-value">0</span>, <span class="ruby-ivar">@lead_tys</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">b</span>].<span class="ruby-identifier">max</span> <span class="ruby-operator">..</span> (<span class="ruby-identifier">idx</span>.<span class="ruby-identifier">exclude_end?</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">e</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">e</span>)
          <span class="ruby-identifier">rest_ty</span> = <span class="ruby-ivar">@lead_tys</span>[<span class="ruby-identifier">range</span>].<span class="ruby-identifier">inject</span>(<span class="ruby-identifier">rest_ty</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">ty0</span>, <span class="ruby-identifier">ty1</span><span class="ruby-operator">|</span> <span class="ruby-identifier">ty0</span>.<span class="ruby-identifier">union</span>(<span class="ruby-identifier">ty1</span>) }
        <span class="ruby-keyword">else</span>
          <span class="ruby-keyword">if</span> <span class="ruby-identifier">b</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">e</span>
            <span class="ruby-identifier">range</span> = [<span class="ruby-value">0</span>, <span class="ruby-ivar">@lead_tys</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">b</span>].<span class="ruby-identifier">max</span> <span class="ruby-operator">..</span> (<span class="ruby-identifier">idx</span>.<span class="ruby-identifier">exclude_end?</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">e</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">e</span>)
            <span class="ruby-identifier">rest_ty</span> = <span class="ruby-ivar">@lead_tys</span>[<span class="ruby-identifier">range</span>].<span class="ruby-identifier">inject</span>(<span class="ruby-ivar">@rest_ty</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">ty0</span>, <span class="ruby-identifier">ty1</span><span class="ruby-operator">|</span> <span class="ruby-identifier">ty0</span>.<span class="ruby-identifier">union</span>(<span class="ruby-identifier">ty1</span>) }
          <span class="ruby-keyword">else</span>
            <span class="ruby-keyword">return</span> <span class="ruby-constant">Type</span>.<span class="ruby-identifier">nil</span>
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">base_ty</span> = <span class="ruby-constant">Type</span><span class="ruby-operator">::</span><span class="ruby-constant">Instance</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Type</span><span class="ruby-operator">::</span><span class="ruby-constant">Builtin</span>[<span class="ruby-value">:ary</span>])
    <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Elements</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">lead_tys</span>, <span class="ruby-identifier">rest_ty</span>), <span class="ruby-identifier">base_ty</span>)
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">idx</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-value">0</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">idx</span> <span class="ruby-operator">&lt;</span> <span class="ruby-ivar">@lead_tys</span>.<span class="ruby-identifier">size</span>
      <span class="ruby-ivar">@lead_tys</span>[<span class="ruby-identifier">idx</span>]
    <span class="ruby-keyword">elsif</span> <span class="ruby-ivar">@rest_ty</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Type</span>.<span class="ruby-identifier">bot</span>
      <span class="ruby-constant">Type</span>.<span class="ruby-identifier">nil</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-ivar">@rest_ty</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">i</span> = <span class="ruby-ivar">@lead_tys</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">idx</span>
    <span class="ruby-identifier">i</span> = [<span class="ruby-identifier">i</span>, <span class="ruby-value">0</span>].<span class="ruby-identifier">max</span>
    <span class="ruby-identifier">ty</span> = <span class="ruby-ivar">@rest_ty</span>
    <span class="ruby-ivar">@lead_tys</span>[<span class="ruby-identifier">i</span><span class="ruby-operator">..</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ty2</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">ty</span> = <span class="ruby-identifier">ty</span>.<span class="ruby-identifier">union</span>(<span class="ruby-identifier">ty2</span>)
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">ty</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-append" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">append</span><span
                                class="method-args">(ty)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="append-source">
            <pre><span class="ruby-comment"># File typeprof-0.21.8/lib/typeprof/container-type.rb, line 477</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">append</span>(<span class="ruby-identifier">ty</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@rest_ty</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Type</span>.<span class="ruby-identifier">bot</span>
    <span class="ruby-keyword">if</span> <span class="ruby-ivar">@lead_tys</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">5</span> <span class="ruby-comment"># XXX: should be configurable, or ...?</span>
      <span class="ruby-identifier">lead_tys</span> = <span class="ruby-ivar">@lead_tys</span> <span class="ruby-operator">+</span> [<span class="ruby-identifier">ty</span>]
      <span class="ruby-constant">Elements</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">lead_tys</span>, <span class="ruby-ivar">@rest_ty</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-constant">Elements</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@lead_tys</span>, <span class="ruby-identifier">ty</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-constant">Elements</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@lead_tys</span>, <span class="ruby-ivar">@rest_ty</span>.<span class="ruby-identifier">union</span>(<span class="ruby-identifier">ty</span>))
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-each_free_type_variable" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">each_free_type_variable</span><span
                                class="method-args">(&amp;blk)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="each_free_type_variable-source">
            <pre><span class="ruby-comment"># File typeprof-0.21.8/lib/typeprof/container-type.rb, line 351</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">each_free_type_variable</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">blk</span>)
  <span class="ruby-ivar">@lead_tys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ty</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">ty</span>.<span class="ruby-identifier">each_free_type_variable</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">blk</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-ivar">@rest_ty</span>&amp;.<span class="ruby-identifier">each_free_type_variable</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">blk</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-globalize" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">globalize</span><span
                                class="method-args">(env, visited, depth)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="globalize-source">
            <pre><span class="ruby-comment"># File typeprof-0.21.8/lib/typeprof/container-type.rb, line 284</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">globalize</span>(<span class="ruby-identifier">env</span>, <span class="ruby-identifier">visited</span>, <span class="ruby-identifier">depth</span>)
  <span class="ruby-identifier">lead_tys</span> = []
  <span class="ruby-ivar">@lead_tys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ty</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">lead_tys</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">ty</span>.<span class="ruby-identifier">globalize</span>(<span class="ruby-identifier">env</span>, <span class="ruby-identifier">visited</span>, <span class="ruby-identifier">depth</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">rest_ty</span> = <span class="ruby-ivar">@rest_ty</span>&amp;.<span class="ruby-identifier">globalize</span>(<span class="ruby-identifier">env</span>, <span class="ruby-identifier">visited</span>, <span class="ruby-identifier">depth</span>)
  <span class="ruby-constant">Elements</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">lead_tys</span>, <span class="ruby-identifier">rest_ty</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-include_untyped-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">include_untyped?</span><span
                                class="method-args">(scratch)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="include_untyped-3F-source">
            <pre><span class="ruby-comment"># File typeprof-0.21.8/lib/typeprof/container-type.rb, line 553</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">include_untyped?</span>(<span class="ruby-identifier">scratch</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@lead_tys</span>.<span class="ruby-identifier">any?</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">ty</span><span class="ruby-operator">|</span> <span class="ruby-identifier">ty</span>.<span class="ruby-identifier">include_untyped?</span>(<span class="ruby-identifier">scratch</span>) }
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@rest_ty</span>.<span class="ruby-identifier">include_untyped?</span>(<span class="ruby-identifier">scratch</span>)
  <span class="ruby-keyword">false</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-limit_size" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">limit_size</span><span
                                class="method-args">(limit)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="limit_size-source">
            <pre><span class="ruby-comment"># File typeprof-0.21.8/lib/typeprof/container-type.rb, line 304</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">limit_size</span>(<span class="ruby-identifier">limit</span>)
  <span class="ruby-constant">Elements</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@lead_tys</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">ty</span><span class="ruby-operator">|</span> <span class="ruby-identifier">ty</span>.<span class="ruby-identifier">limit_size</span>(<span class="ruby-identifier">limit</span>) }, <span class="ruby-ivar">@rest_ty</span>.<span class="ruby-identifier">limit_size</span>(<span class="ruby-identifier">limit</span>))
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-localize" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">localize</span><span
                                class="method-args">(env, alloc_site, depth)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="localize-source">
            <pre><span class="ruby-comment"># File typeprof-0.21.8/lib/typeprof/container-type.rb, line 293</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">localize</span>(<span class="ruby-identifier">env</span>, <span class="ruby-identifier">alloc_site</span>, <span class="ruby-identifier">depth</span>)
  <span class="ruby-identifier">lead_tys</span> = <span class="ruby-ivar">@lead_tys</span>.<span class="ruby-identifier">map</span>.<span class="ruby-identifier">with_index</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ty</span>, <span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">alloc_site2</span> = <span class="ruby-identifier">alloc_site</span>.<span class="ruby-identifier">add_id</span>(<span class="ruby-identifier">i</span>)
    <span class="ruby-identifier">env</span>, <span class="ruby-identifier">ty</span> = <span class="ruby-identifier">ty</span>.<span class="ruby-identifier">localize</span>(<span class="ruby-identifier">env</span>, <span class="ruby-identifier">alloc_site2</span>, <span class="ruby-identifier">depth</span>)
    <span class="ruby-identifier">ty</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">alloc_site_rest</span> = <span class="ruby-identifier">alloc_site</span>.<span class="ruby-identifier">add_id</span>(<span class="ruby-value">:rest</span>)
  <span class="ruby-identifier">env</span>, <span class="ruby-identifier">rest_ty</span> = <span class="ruby-ivar">@rest_ty</span>.<span class="ruby-identifier">localize</span>(<span class="ruby-identifier">env</span>, <span class="ruby-identifier">alloc_site_rest</span>, <span class="ruby-identifier">depth</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">env</span>, <span class="ruby-constant">Elements</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">lead_tys</span>, <span class="ruby-identifier">rest_ty</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-match-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">match?</span><span
                                class="method-args">(other)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="match-3F-source">
            <pre><span class="ruby-comment"># File typeprof-0.21.8/lib/typeprof/container-type.rb, line 338</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">match?</span>(<span class="ruby-identifier">other</span>)
  <span class="ruby-identifier">n</span> = [<span class="ruby-ivar">@lead_tys</span>.<span class="ruby-identifier">size</span>, <span class="ruby-identifier">other</span>.<span class="ruby-identifier">lead_tys</span>.<span class="ruby-identifier">size</span>].<span class="ruby-identifier">min</span>
  <span class="ruby-identifier">rest_ty1</span> = <span class="ruby-ivar">@lead_tys</span>[<span class="ruby-identifier">n</span><span class="ruby-operator">..</span>].<span class="ruby-identifier">inject</span>(<span class="ruby-ivar">@rest_ty</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">ty1</span>, <span class="ruby-identifier">ty2</span><span class="ruby-operator">|</span> <span class="ruby-identifier">ty1</span>.<span class="ruby-identifier">union</span>(<span class="ruby-identifier">ty2</span>) }
  <span class="ruby-identifier">rest_ty2</span> = <span class="ruby-identifier">other</span>.<span class="ruby-identifier">lead_tys</span>[<span class="ruby-identifier">n</span><span class="ruby-operator">..</span>].<span class="ruby-identifier">inject</span>(<span class="ruby-identifier">other</span>.<span class="ruby-identifier">rest_ty</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">ty1</span>, <span class="ruby-identifier">ty2</span><span class="ruby-operator">|</span> <span class="ruby-identifier">ty1</span>.<span class="ruby-identifier">union</span>(<span class="ruby-identifier">ty2</span>) }
  <span class="ruby-identifier">subst</span> = <span class="ruby-keyword">nil</span>
  (<span class="ruby-ivar">@lead_tys</span>[<span class="ruby-value">0</span>, <span class="ruby-identifier">n</span>] <span class="ruby-operator">+</span> [<span class="ruby-identifier">rest_ty1</span>]).<span class="ruby-identifier">zip</span>(<span class="ruby-identifier">other</span>.<span class="ruby-identifier">lead_tys</span>[<span class="ruby-value">0</span>, <span class="ruby-identifier">n</span>] <span class="ruby-operator">+</span> [<span class="ruby-identifier">rest_ty2</span>]) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ty0</span>, <span class="ruby-identifier">ty1</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">subst2</span> = <span class="ruby-constant">Type</span>.<span class="ruby-identifier">match?</span>(<span class="ruby-identifier">ty0</span>, <span class="ruby-identifier">ty1</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">subst2</span>
    <span class="ruby-identifier">subst</span> = <span class="ruby-constant">Type</span>.<span class="ruby-identifier">merge_substitution</span>(<span class="ruby-identifier">subst</span>, <span class="ruby-identifier">subst2</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">subst</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-pretty_print" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">pretty_print</span><span
                                class="method-args">(q)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="pretty_print-source">
            <pre><span class="ruby-comment"># File typeprof-0.21.8/lib/typeprof/container-type.rb, line 330</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">pretty_print</span>(<span class="ruby-identifier">q</span>)
  <span class="ruby-identifier">q</span>.<span class="ruby-identifier">group</span>(<span class="ruby-value">9</span>, <span class="ruby-string">&quot;Elements[&quot;</span>, <span class="ruby-string">&quot;]&quot;</span>) <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">q</span>.<span class="ruby-identifier">seplist</span>(<span class="ruby-ivar">@lead_tys</span> <span class="ruby-operator">+</span> [<span class="ruby-ivar">@rest_ty</span>]) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">elem</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">q</span>.<span class="ruby-identifier">pp</span> <span class="ruby-identifier">elem</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-screen_name" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">screen_name</span><span
                                class="method-args">(scratch)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="screen_name-source">
            <pre><span class="ruby-comment"># File typeprof-0.21.8/lib/typeprof/container-type.rb, line 308</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">screen_name</span>(<span class="ruby-identifier">scratch</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@rest_ty</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Type</span>.<span class="ruby-identifier">bot</span>
    <span class="ruby-keyword">if</span> <span class="ruby-ivar">@lead_tys</span>.<span class="ruby-identifier">empty?</span>
      <span class="ruby-comment"># This is heuristic: in general, an empty array is a wrong guess.</span>
      <span class="ruby-comment"># Note that an empty array is representable as &quot;[ ]&quot; in RBS, but</span>
      <span class="ruby-comment"># users often have to modify it to &quot;Array[something]&quot;.</span>
      <span class="ruby-comment"># In this term, &quot;Array[untyped]&quot; is considered more useful than &quot;[ ]&quot;.</span>
      <span class="ruby-keyword">return</span> <span class="ruby-string">&quot;Array[untyped]&quot;</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">s</span> = <span class="ruby-ivar">@lead_tys</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ty</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">ty</span>.<span class="ruby-identifier">screen_name</span>(<span class="ruby-identifier">scratch</span>)
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">s</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;*&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@rest_ty</span>.<span class="ruby-identifier">screen_name</span>(<span class="ruby-identifier">scratch</span>) <span class="ruby-keyword">if</span> <span class="ruby-ivar">@rest_ty</span> <span class="ruby-operator">!=</span> <span class="ruby-constant">Type</span>.<span class="ruby-identifier">bot</span>
    <span class="ruby-keyword">return</span> <span class="ruby-node">&quot;[#{ s.join(&quot;, &quot;) }]&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-node">&quot;*[#{ squash.screen_name(scratch) }]&quot;</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">SystemStackError</span>
  <span class="ruby-identifier">p</span> <span class="ruby-identifier">squash</span>
  <span class="ruby-identifier">exit!</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-squash" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">squash</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="squash-source">
            <pre><span class="ruby-comment"># File typeprof-0.21.8/lib/typeprof/container-type.rb, line 364</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">squash</span>
  <span class="ruby-ivar">@lead_tys</span>.<span class="ruby-identifier">inject</span>(<span class="ruby-ivar">@rest_ty</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">ty1</span>, <span class="ruby-identifier">ty2</span><span class="ruby-operator">|</span> <span class="ruby-identifier">ty1</span>.<span class="ruby-identifier">union</span>(<span class="ruby-identifier">ty2</span>) } <span class="ruby-comment">#.union(Type.nil) # is this needed?</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-squash_or_any" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">squash_or_any</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="squash_or_any-source">
            <pre><span class="ruby-comment"># File typeprof-0.21.8/lib/typeprof/container-type.rb, line 368</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">squash_or_any</span>
  <span class="ruby-identifier">ty</span> = <span class="ruby-identifier">squash</span>
  <span class="ruby-identifier">ty</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Type</span>.<span class="ruby-identifier">bot</span> <span class="ruby-operator">?</span> <span class="ruby-constant">Type</span>.<span class="ruby-identifier">any</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">ty</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-substitute" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">substitute</span><span
                                class="method-args">(subst, depth)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="substitute-source">
            <pre><span class="ruby-comment"># File typeprof-0.21.8/lib/typeprof/container-type.rb, line 358</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">substitute</span>(<span class="ruby-identifier">subst</span>, <span class="ruby-identifier">depth</span>)
  <span class="ruby-identifier">lead_tys</span> = <span class="ruby-ivar">@lead_tys</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">ty</span><span class="ruby-operator">|</span> <span class="ruby-identifier">ty</span>.<span class="ruby-identifier">substitute</span>(<span class="ruby-identifier">subst</span>, <span class="ruby-identifier">depth</span>) }
  <span class="ruby-identifier">rest_ty</span> = <span class="ruby-ivar">@rest_ty</span>.<span class="ruby-identifier">substitute</span>(<span class="ruby-identifier">subst</span>, <span class="ruby-identifier">depth</span>)
  <span class="ruby-constant">Elements</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">lead_tys</span>, <span class="ruby-identifier">rest_ty</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-take_first" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">take_first</span><span
                                class="method-args">(num)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="take_first-source">
            <pre><span class="ruby-comment"># File typeprof-0.21.8/lib/typeprof/container-type.rb, line 507</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">take_first</span>(<span class="ruby-identifier">num</span>)
  <span class="ruby-identifier">base_ty</span> = <span class="ruby-constant">Type</span><span class="ruby-operator">::</span><span class="ruby-constant">Instance</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Type</span><span class="ruby-operator">::</span><span class="ruby-constant">Builtin</span>[<span class="ruby-value">:ary</span>])
  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@lead_tys</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-identifier">num</span>
    <span class="ruby-identifier">lead_tys</span> = <span class="ruby-ivar">@lead_tys</span>[<span class="ruby-value">0</span>, <span class="ruby-identifier">num</span>]
    <span class="ruby-identifier">rest_ary_ty</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Elements</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@lead_tys</span>[<span class="ruby-identifier">num</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>], <span class="ruby-ivar">@rest_ty</span>), <span class="ruby-identifier">base_ty</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">lead_tys</span>, <span class="ruby-identifier">rest_ary_ty</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">lead_tys</span> = <span class="ruby-ivar">@lead_tys</span>.<span class="ruby-identifier">dup</span>
    <span class="ruby-keyword">until</span> <span class="ruby-identifier">lead_tys</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">num</span>
      <span class="ruby-comment"># .union(Type.nil) is needed for `a, b, c = [42]` to assign nil to b and c</span>
      <span class="ruby-identifier">lead_tys</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-ivar">@rest_ty</span>.<span class="ruby-identifier">union</span>(<span class="ruby-constant">Type</span>.<span class="ruby-identifier">nil</span>)
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">rest_ary_ty</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Elements</span>.<span class="ruby-identifier">new</span>([], <span class="ruby-ivar">@rest_ty</span>), <span class="ruby-identifier">base_ty</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">lead_tys</span>, <span class="ruby-identifier">rest_ary_ty</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-take_last" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">take_last</span><span
                                class="method-args">(num)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="take_last-source">
            <pre><span class="ruby-comment"># File typeprof-0.21.8/lib/typeprof/container-type.rb, line 524</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">take_last</span>(<span class="ruby-identifier">num</span>)
  <span class="ruby-identifier">base_ty</span> = <span class="ruby-constant">Type</span><span class="ruby-operator">::</span><span class="ruby-constant">Instance</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Type</span><span class="ruby-operator">::</span><span class="ruby-constant">Builtin</span>[<span class="ruby-value">:ary</span>])
  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@rest_ty</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Type</span>.<span class="ruby-identifier">bot</span>
    <span class="ruby-keyword">if</span> <span class="ruby-ivar">@lead_tys</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-identifier">num</span>
      <span class="ruby-identifier">following_tys</span> = <span class="ruby-ivar">@lead_tys</span>[<span class="ruby-operator">-</span><span class="ruby-identifier">num</span>, <span class="ruby-identifier">num</span>]
      <span class="ruby-identifier">rest_ary_ty</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Elements</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@lead_tys</span>[<span class="ruby-value">0</span><span class="ruby-operator">...</span><span class="ruby-operator">-</span><span class="ruby-identifier">num</span>], <span class="ruby-constant">Type</span>.<span class="ruby-identifier">bot</span>), <span class="ruby-identifier">base_ty</span>)
      <span class="ruby-keyword">return</span> <span class="ruby-identifier">rest_ary_ty</span>, <span class="ruby-identifier">following_tys</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">following_tys</span> = <span class="ruby-ivar">@lead_tys</span>[<span class="ruby-operator">-</span><span class="ruby-identifier">num</span>, <span class="ruby-identifier">num</span>] <span class="ruby-operator">||</span> []
      <span class="ruby-keyword">until</span> <span class="ruby-identifier">following_tys</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">num</span>
        <span class="ruby-identifier">following_tys</span>.<span class="ruby-identifier">unshift</span>(<span class="ruby-constant">Type</span>.<span class="ruby-identifier">nil</span>)
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">rest_ary_ty</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Elements</span>.<span class="ruby-identifier">new</span>([], <span class="ruby-constant">Type</span>.<span class="ruby-identifier">bot</span>), <span class="ruby-identifier">base_ty</span>)
      <span class="ruby-keyword">return</span> <span class="ruby-identifier">rest_ary_ty</span>, <span class="ruby-identifier">following_tys</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">lead_tys</span> = <span class="ruby-ivar">@lead_tys</span>.<span class="ruby-identifier">dup</span>
    <span class="ruby-identifier">last_ty</span> = <span class="ruby-identifier">rest_ty</span>
    <span class="ruby-identifier">following_tys</span> = []
    <span class="ruby-keyword">until</span> <span class="ruby-identifier">following_tys</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">num</span>
      <span class="ruby-identifier">last_ty</span> = <span class="ruby-identifier">last_ty</span>.<span class="ruby-identifier">union</span>(<span class="ruby-identifier">lead_tys</span>.<span class="ruby-identifier">pop</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">lead_tys</span>.<span class="ruby-identifier">empty?</span>
      <span class="ruby-identifier">following_tys</span>.<span class="ruby-identifier">unshift</span>(<span class="ruby-identifier">last_ty</span>)
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">rest_ty</span> = <span class="ruby-identifier">lead_tys</span>.<span class="ruby-identifier">inject</span>(<span class="ruby-identifier">last_ty</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">ty1</span>, <span class="ruby-identifier">ty2</span><span class="ruby-operator">|</span> <span class="ruby-identifier">ty1</span>.<span class="ruby-identifier">union</span>(<span class="ruby-identifier">ty2</span>) }
    <span class="ruby-identifier">rest_ary_ty</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Elements</span>.<span class="ruby-identifier">new</span>([], <span class="ruby-identifier">rest_ty</span>), <span class="ruby-identifier">base_ty</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">rest_ary_ty</span>, <span class="ruby-identifier">following_tys</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_local_type" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">to_local_type</span><span
                                class="method-args">(id, base_ty)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="to_local_type-source">
            <pre><span class="ruby-comment"># File typeprof-0.21.8/lib/typeprof/container-type.rb, line 280</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">to_local_type</span>(<span class="ruby-identifier">id</span>, <span class="ruby-identifier">base_ty</span>)
  <span class="ruby-constant">Type</span><span class="ruby-operator">::</span><span class="ruby-constant">Local</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Array</span>, <span class="ruby-identifier">id</span>, <span class="ruby-identifier">base_ty</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-union" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">union</span><span
                                class="method-args">(other)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="union-source">
            <pre><span class="ruby-comment"># File typeprof-0.21.8/lib/typeprof/container-type.rb, line 490</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">union</span>(<span class="ruby-identifier">other</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">self</span> <span class="ruby-keyword">if</span> <span class="ruby-keyword">self</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">other</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-string">&quot;Hash::Elements merge Array::Elements&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span><span class="ruby-operator">::</span><span class="ruby-constant">Elements</span>)

  <span class="ruby-identifier">lead_count</span> = [<span class="ruby-ivar">@lead_tys</span>.<span class="ruby-identifier">size</span>, <span class="ruby-identifier">other</span>.<span class="ruby-identifier">lead_tys</span>.<span class="ruby-identifier">size</span>].<span class="ruby-identifier">min</span>
  <span class="ruby-identifier">lead_tys</span> = (<span class="ruby-value">0</span><span class="ruby-operator">...</span><span class="ruby-identifier">lead_count</span>).<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
    <span class="ruby-ivar">@lead_tys</span>[<span class="ruby-identifier">i</span>].<span class="ruby-identifier">union</span>(<span class="ruby-identifier">other</span>.<span class="ruby-identifier">lead_tys</span>[<span class="ruby-identifier">i</span>])
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">rest_ty</span> = <span class="ruby-ivar">@rest_ty</span>.<span class="ruby-identifier">union</span>(<span class="ruby-identifier">other</span>.<span class="ruby-identifier">rest_ty</span>)
  (<span class="ruby-ivar">@lead_tys</span>[<span class="ruby-identifier">lead_count</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>] <span class="ruby-operator">+</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">lead_tys</span>[<span class="ruby-identifier">lead_count</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>]).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ty</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">rest_ty</span> = <span class="ruby-identifier">rest_ty</span>.<span class="ruby-identifier">union</span>(<span class="ruby-identifier">ty</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-constant">Elements</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">lead_tys</span>, <span class="ruby-identifier">rest_ty</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-update" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">update</span><span
                                class="method-args">(idx, ty)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="update-source">
            <pre><span class="ruby-comment"># File typeprof-0.21.8/lib/typeprof/container-type.rb, line 443</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">update</span>(<span class="ruby-identifier">idx</span>, <span class="ruby-identifier">ty</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">idx</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">idx</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-value">0</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">idx</span> <span class="ruby-operator">&lt;</span> <span class="ruby-ivar">@lead_tys</span>.<span class="ruby-identifier">size</span>
        <span class="ruby-identifier">lead_tys</span> = <span class="ruby-constant">Utils</span>.<span class="ruby-identifier">array_update</span>(<span class="ruby-ivar">@lead_tys</span>, <span class="ruby-identifier">idx</span>, <span class="ruby-identifier">ty</span>)
        <span class="ruby-constant">Elements</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">lead_tys</span>, <span class="ruby-ivar">@rest_ty</span>)
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">rest_ty</span> = <span class="ruby-ivar">@rest_ty</span>.<span class="ruby-identifier">union</span>(<span class="ruby-identifier">ty</span>)
        <span class="ruby-constant">Elements</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@lead_tys</span>, <span class="ruby-identifier">rest_ty</span>)
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">i</span> = <span class="ruby-ivar">@lead_tys</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">idx</span>
      <span class="ruby-keyword">if</span> <span class="ruby-ivar">@rest_ty</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Type</span>.<span class="ruby-identifier">bot</span>
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-value">0</span>
          <span class="ruby-identifier">lead_tys</span> = <span class="ruby-constant">Utils</span>.<span class="ruby-identifier">array_update</span>(<span class="ruby-ivar">@lead_tys</span>, <span class="ruby-identifier">i</span>, <span class="ruby-identifier">ty</span>)
          <span class="ruby-constant">Elements</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">lead_tys</span>, <span class="ruby-constant">Type</span>.<span class="ruby-identifier">bot</span>)
        <span class="ruby-keyword">else</span>
          <span class="ruby-comment"># TODO: out of bound? should we emit an error?</span>
          <span class="ruby-constant">Elements</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@lead_tys</span>, <span class="ruby-constant">Type</span>.<span class="ruby-identifier">bot</span>)
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">i</span> = [<span class="ruby-identifier">i</span>, <span class="ruby-value">0</span>].<span class="ruby-identifier">max</span>
        <span class="ruby-identifier">lead_tys</span> = <span class="ruby-ivar">@lead_tys</span>[<span class="ruby-value">0</span>, <span class="ruby-identifier">i</span>] <span class="ruby-operator">+</span> <span class="ruby-ivar">@lead_tys</span>[<span class="ruby-identifier">i</span><span class="ruby-operator">..</span>].<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">ty2</span><span class="ruby-operator">|</span> <span class="ruby-identifier">ty2</span>.<span class="ruby-identifier">union</span>(<span class="ruby-identifier">ty</span>) }
        <span class="ruby-identifier">rest_ty</span> = <span class="ruby-ivar">@rest_ty</span>.<span class="ruby-identifier">union</span>(<span class="ruby-identifier">ty</span>)
        <span class="ruby-constant">Elements</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@lead_tys</span>, <span class="ruby-identifier">rest_ty</span>)
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">lead_tys</span> = <span class="ruby-ivar">@lead_tys</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">ty1</span><span class="ruby-operator">|</span> <span class="ruby-identifier">ty1</span>.<span class="ruby-identifier">union</span>(<span class="ruby-identifier">ty</span>) }
    <span class="ruby-identifier">rest_ty</span> = <span class="ruby-ivar">@rest_ty</span>.<span class="ruby-identifier">union</span>(<span class="ruby-identifier">ty</span>)
    <span class="ruby-constant">Elements</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">lead_tys</span>, <span class="ruby-identifier">rest_ty</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is a service of <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>, purveyors of fine <a href='https://jamesbritt.bandcamp.com/'>dance noise</a></p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

